///*
// * Copyright (c) 2016-2017 fulihui.com All right reserved
// * Project: information-core-170307
// * File name: UserIdSingleKeyTableShardingAlgorithm.java
// */
//
//package com.fulihui.information.dal.shard;
//
//import io.shardingsphere.core.api.algorithm.sharding.PreciseShardingValue;
//import io.shardingsphere.core.api.algorithm.sharding.standard.PreciseShardingAlgorithm;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.builder.HashCodeBuilder;
//
//import java.util.Collection;
//
///**
// * @author Willard.Hu on 2017/2/17 0017.
// */
//@Slf4j
//public class RewardUserIdSingleKeyTableShardingAlgorithm implements PreciseShardingAlgorithm<String> {
//    private final int TABLE_COUNT = 10;
//
//    private final String DEFAULT_TABLE = "info_user_behavior_reward";
//
//    /**
//     * 分表策略，根据userid的hash值 跟TABLE_COUNT进行取余
//     *
//     * @param availableTargetNames
//     * @param shardingValue
//     * @return
//     */
//    @Override
//    public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<String> shardingValue) {
//        Integer suffix = Math.abs(
//                new HashCodeBuilder().append(shardingValue.getValue()).hashCode() % TABLE_COUNT);
//        for (String each : availableTargetNames) {
//            if (each.endsWith("_" + suffix)) {
//                return each;
//            }
//        }
//        log.info("TbUsrWechatUserShardingAlgorithm,没有路由到表，shardingValue：{}", shardingValue.getValue());
//        return DEFAULT_TABLE;
//    }
//
//}
